package com.example.zhaoapplication;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void click1(View view) {
        EditText user=findViewById(R.id.user);
        String u = user.getText().toString();
        EditText password =findViewById(R.id.password);
        String p = password.getText().toString();
        if(u.equals("zjl")&&p.equals("123456")){
            AlertDialog dialog=new AlertDialog.Builder(this).setTitle("信息提示框").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            })
                    .setMessage("登录成功")
                    .create();
            dialog.show();
        }
        else {
            AlertDialog dialog=new AlertDialog.Builder(this).setTitle("信息提示框").setPositiveButton("确定", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            })
                    .setMessage("账户或密码错误登陆失败")
                    .create();
            dialog.show();
        }

    }

    public void click2(View view) {
        Intent intent=new Intent();
        intent.setClass(this, Register.class);
        startActivity(intent);
    }
}